using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Office = Microsoft.Office.Core;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using System.Reflection;
using stdole;

namespace Investafinance
{
    /// <summary>
    /// The MyAxHost is derived from AxHost to use the function
    /// AxHost.GetIPictureDispFromPicture(image);
    /// that returns an IPictureDisp interface from an Image.
    /// </summary>
    internal class MyAxHost : System.Windows.Forms.AxHost
    {

        /// <summary>
        /// Overloaded constructor with CLSID for the ribbon
        /// </summary>
        public MyAxHost()
            : base("{59EE46BA-677D-4d20-BF10-8D8067CB8B33}")
        {
        }

        //public stdole.IPictureDisp IPictureDispFromImage(System.Drawing.Bitmap image)
        public stdole.IPictureDisp IPictureDispFromImage(System.Drawing.Image image)
        {
            IPictureDisp oPic = null;

            try
            {
                // Convert the Resource bitmap to stdole.IPictureDisp
                oPic = (stdole.IPictureDisp)AxHost.GetIPictureDispFromPicture(image);
                return oPic;
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return oPic;
            }
        }
    }
}
